#-*- encoding: gb2312 -*-  
import sys  
import time
import pamie as p
import unzip
import findFile
import callVBA
import getFiles
reload(sys)   
sys.setdefaultencoding('gb2312')
 


if __name__ == "__main__":
	wp = 'D:/pyTemp'
	
	
	'''
	# Step 1:
	# first get all the zip file from sql change system
	ie = p.PAMIE('http://10.1.64.21/SoftPlat/SoftPlat_Query/Query_UnCloseChange.aspx')
	lns = ie.getLinks()

	for n in range(1,len(lns) - 2):
		ln = lns[n].getAttribute('href')
		if len(ln) == 70:
			print n
			getFiles.getSubLinks(ln,wp+'/zipFiles')
	ie.quit()
	
	# Step 2:
	# unzip the zip file into folder $wp
	unzip.unzip(wp+'/zipFiles',wp+'/extractFiles')
	
	# Step 3:
	#find file path and write into txt file
	f = open(wp+'/path.txt','w')
	fs = findFile.findFiles(wp+'/extractFiles')
	for i in fs:
		print "path : " ,i
		f.write(i+'\n')
		#break
	f.close()
	
	'''
	# Step 4:
	# call the vba by the paths stored at path.txt
	callVBA.callVBA(wp+'/host.xls','main','')